﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Pibby.Core.Tests
{
	[TestClass]
	public class EpisodeCollectionTests
	{
		[TestMethod]
		public void CannotIndexEmptyCollection()
		{
			EpisodeCollection collect = new EpisodeCollection();

			Episode missing = collect["not expecting to find anything"];

			Assert.IsNull(missing);
		}

		[TestMethod]
		public void CannotFindMissingItem()
		{
			EpisodeCollection collect = new EpisodeCollection();

			Episode ep = new Episode()
			{
				Name = "Example",
				Feed = new Uri ("http://example.com/1")
			};

			collect.Add(ep);

			Episode missing = collect["not expecting to find this"];

			Assert.IsNull(missing);
		}
				

		[TestMethod]
		public void CanIndexSingleItemByUri()
		{
			EpisodeCollection collect = new EpisodeCollection();

			Uri uri = new Uri("http://p1.com/");
			Episode e = new Episode("p1", uri, "123456789");

			collect.Add(e);

			Episode e2 = collect[e.Id];
			Assert.AreEqual(e, e2);
		}

		[TestMethod]
		public void CanIndexSingleItemByGuid()
		{
			EpisodeCollection collect = new EpisodeCollection();

			Uri uri = new Uri("http://p1.com/");
			Episode e = new Episode("p1", uri, "123456789");

			collect.Add(e);

			Episode e2 = collect[e.Id];
			Assert.AreEqual(e, e2);
		}
	}
}
